package com.atguigu02.singleton;

/**
 * ClassName: PersonTest
 * Description:
 *  懒汉式
 * @Author liu
 * @Create 2024/11/1 11:24
 * @Version 1.0
 */
public class GirlFriendTest {

}

/**
 * 懒汉式
 */
class GirlFriend{
    //1.类的构造器私有化
    private GirlFriend(){
    }

    //2.声明当前类的实例
    //3. 此属性也必须声明为static的
    private static GirlFriend instance = null;

    //4.通过getXxx()获取当前类的实例，
    // 如果未创建对象，则在方法内部进行创建
    public static GirlFriend getInstance(){
        if(instance == null){
            instance = new GirlFriend();
      //      return instance;
        }
        return instance;
    }
}